package com.ruoyi.mateCheck.controller;

import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mateCheck.domain.MateCheck;
import com.ruoyi.mateCheck.domain.MateTest;
import com.ruoyi.mateCheck.service.MateTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author
 * @Version 1.0
 */
@RestController
@RequestMapping("/mateTest")
public class MateTestController  extends BaseController {
    @Autowired
    MateTestService mateTestService;

    /*
     * 查询实验记录
     */
    @GetMapping("/selectTestRecord")
    @ResponseBody
    public TableDataInfo selectTestRecord(@RequestParam(value = "beginTime", required = false) String beginTime,
                                          @RequestParam(value = "endTime", required = false) String endTime) {
        MateTest mateTest = new MateTest();
        mateTest.setBeginTime(beginTime);
        mateTest.setEndTime(endTime);
        startPage();
        mateTest.setDeptId(SecurityUtils.getLoginUser().getUser().getCompanyId());
        List<MateTest> list = mateTestService.selectTestRecord(mateTest);
        return getDataTable(list);
    }

    /*
  查询具体的实验记录
    */
    @GetMapping("/selectEdit")
    public MateTest selectEdit(@RequestParam(value = "testId", required = false) Long testId) {
        MateTest mateTest = mateTestService.selectEdit(testId);
        return mateTest;
    }

}
